using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

namespace ApplicationProject
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DirectoryInfo dir = new
                    DirectoryInfo(@"C:\WINDOWS\");
                int i = 1;
                int max = dir.GetFiles("*.*").Length;
                progressBar1.Maximum = max;
                foreach (FileInfo d in dir.GetFiles("*.*"))
                {
                    label1.Text = d.Name;
                    progressBar1.Value = i;
                    int j = Convert.ToInt32(
                    Math.Floor(Convert.ToDouble(i * 100 / max)));
                    label2.Text = Convert.ToString(j) + "%";
                    i++;
                     

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}